
/*
 * Copyright 2002-2018 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2018原创作者。
 *
 *根据Apache许可证2.0版许可（“许可证”）；
 *除非符合许可证的规定，否则您不得使用此文件。
 *您可以在以下网址获取许可证副本：
 *
 *https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，软件
 *根据许可证进行的分发是在“按原样”的基础上进行的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限的特定语言，请参阅许可证和
 *许可证下的限制。
 */

package org.springframework.validation;

import org.springframework.lang.Nullable;

/**
 * Extended variant of the {@link Validator} interface, adding support for
 * validation 'hints'.
 *
 * @author Juergen Hoeller
 * @author Sam Brannen
 * @since 3.1
 */
/**
 *｛@link Validator｝接口的扩展变体，添加了对
 *验证“提示”。
 *
 *@作者于尔根·霍勒
 *@作者Sam Brannen
 *@自3.1起
 */
public interface SmartValidator extends Validator {

	/**
	 * Validate the supplied {@code target} object, which must be of a type of {@link Class}
	 * for which the {@link #supports(Class)} method typically returns {@code true}.
	 * <p>The supplied {@link Errors errors} instance can be used to report any
	 * resulting validation errors.
	 * <p><b>This variant of {@code validate()} supports validation hints, such as
	 * validation groups against a JSR-303 provider</b> (in which case, the provided hint
	 * objects need to be annotation arguments of type {@code Class}).
	 * <p>Note: Validation hints may get ignored by the actual target {@code Validator},
	 * in which case this method should behave just like its regular
	 * {@link #validate(Object, Errors)} sibling.
	 * @param target the object that is to be validated
	 * @param errors contextual state about the validation process
	 * @param validationHints one or more hint objects to be passed to the validation engine
	 * @see jakarta.validation.Validator#validate(Object, Class[])
	 */
	/**
	 *验证提供的｛@code target｝对象，该对象的类型必须为｛@link Class｝
	 *｛@link#支持（Class）｝方法通常返回｛@code true｝。
	 *<p>提供的｛@link Errors Errors｝实例可用于报告任何
	 *从而导致验证错误。
	 *<p><b>｛@code validate（）｝的此变体支持验证提示，例如
	 *针对JSR-303提供程序的验证组</b>（在这种情况下，提供的提示
	 *对象需要是类型为｛@code Class｝的注释参数）。
	 *＜p＞注意：验证提示可能会被实际目标｛@code Validator｝忽略，
	 *在这种情况下，该方法的行为应该与其正则方法一样
	 *｛@link#validate（Object，Errors）｝同级。
	 *@param target要验证的对象
	 *@param errors有关验证过程的上下文状态
	 *@param validationHints要传递给验证引擎的一个或多个提示对象
	 *@见jakarta.validation.Validator#validate（Object，Class[]）
	 */
	void validate(Object target, Errors errors, Object... validationHints);

	/**
	 * Validate the supplied value for the specified field on the target type,
	 * reporting the same validation errors as if the value would be bound to
	 * the field on an instance of the target class.
	 * @param targetType the target type
	 * @param fieldName the name of the field
	 * @param value the candidate value
	 * @param errors contextual state about the validation process
	 * @param validationHints one or more hint objects to be passed to the validation engine
	 * @since 5.1
	 * @see jakarta.validation.Validator#validateValue(Class, String, Object, Class[])
	 */
	/**
	 *验证为目标类型上的指定字段提供的值，
	 *报告相同的验证错误，就好像该值将被绑定到
	 *目标类实例上的字段。
	 *@param targetType目标类型
	 *@param fieldName字段的名称
	 *@param value候选值
	 *@param errors有关验证过程的上下文状态
	 *@param validationHints要传递给验证引擎的一个或多个提示对象
	 *@自5.1起
	 *@参见jakarta.validation.Validator#validateValue（Class，String，Object，Class[]）
	 */
	default void validateValue(
			Class<?> targetType, String fieldName, @Nullable Object value, Errors errors, Object... validationHints) {

		throw new IllegalArgumentException("Cannot validate individual value for " + targetType);
	}

}
